package com.ltx.blog_bam.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class IndexController {
    @Autowired
    private RedisTemplate redisTemplate;


    /***
     * 获取近七日的博客发布量，并且返回给前端
     * @return
     */
    @GetMapping("/GetSevenDayList")
    private List GetSevenDayList(){
        return redisTemplate.opsForList().range("SevenDayList", 0, -1);
    }

    /***
     * 返回今日本时段和前面的博客发布量
     * @return
     */
    @GetMapping("/GetHourlyReleaseVolume")
    private  List GetHourlyReleaseVolume(){
        return redisTemplate.opsForList().range("HourlyReleaseVolume", 0, -1);
    }

    @GetMapping("/CheckNum")
    private  List CheckNum(){
        List<Integer> checkNum = new ArrayList<>();
        int passNum = (int) redisTemplate.opsForValue().get("passNum");
        int nopassNum = (int) redisTemplate.opsForValue().get("nopassNum");
        int todayNum = (int) redisTemplate.opsForValue().get("todayNum");
        checkNum.add(passNum);
        checkNum.add(nopassNum);
        checkNum.add(todayNum-nopassNum-passNum);
        return checkNum;
    }

}
